home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blanker / source / blankers / aswarm / prefs.c < prev    next >
C/C++ Source or Header  |  1993-07-25  |  4KB  |  178 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3.  
  4. #include <intuition/intuition.h>
  5. #include <intuition/intuitionbase.h>
  6. #include <intuition/screens.h>
  7.  
  8. #include <libraries/gadtools.h>
  9. #include <dos/dos.h>
  10.  
  11. #include <clib/exec_protos.h>
  12. #include <clib/intuition_protos.h>
  13. #include <clib/gadtools_protos.h>
  14.  
  15. #include "ASwarm.h"
  16. #include "ASwarm_rev.h"
  17. #include "/defs.h"
  18.  
  19. #define MAX_SPEED     6L
  20. #define MAX_WASPS     10L
  21. #define MAX_BEES      500L
  22. #define MAX_TIGHTNESS 10L
  23.  
  24. struct mPrefObject {
  25.     LONG    Wasps, Bees, Tightness, Speed, Colorcycling, Aimmode;
  26. };
  27.  
  28. VOID blank( VOID );
  29.  
  30.     struct    mPrefObject    nP;
  31. STATIC    const    UBYTE        VersTag[] = VERSTAG;
  32. extern    struct    Task        **Task;
  33. extern        ULONG        Depth, Mode;
  34. extern        UBYTE        *prefData;
  35.  
  36. VOID setASwarmPrefs( VOID )
  37. {
  38.     GT_SetGadgetAttrs( ASwarmGadgets[GD_WASPS], ASwarmWnd, 0L, GTSL_Level, nP.Wasps, 0L );
  39.     GT_SetGadgetAttrs( ASwarmGadgets[GD_BEES], ASwarmWnd, 0L, GTSL_Level, nP.Bees, 0L );
  40.     GT_SetGadgetAttrs( ASwarmGadgets[GD_TIGHTNESS], ASwarmWnd, 0L, GTSL_Level, nP.Tightness, 0L );
  41.     GT_SetGadgetAttrs( ASwarmGadgets[GD_SPEED], ASwarmWnd, 0L, GTCY_Active, nP.Speed, 0L );
  42.     GT_SetGadgetAttrs( ASwarmGadgets[GD_COLORCYCLING], ASwarmWnd, 0L, GTCY_Active, nP.Colorcycling, 0L );
  43.     GT_SetGadgetAttrs( ASwarmGadgets[GD_AIMMODE], ASwarmWnd, 0L, GTCY_Active, nP.Aimmode, 0L );
  44. }
  45.  
  46. int OKClicked( VOID )
  47. {
  48.     CopyMem( &nP, prefData, sizeof( struct mPrefObject ));
  49.     return( QUIT );
  50. }
  51.  
  52. int TESTClicked( VOID )
  53. {
  54.     *Task = FindTask( 0L );
  55.     blank();
  56.     return( CONTINUE );
  57. }
  58.  
  59. int CANCELClicked( VOID )
  60. {
  61.     return( QUIT );
  62. }
  63.  
  64. int SPEEDClicked( VOID )
  65. {
  66.     nP.Speed = ASwarmMsg.Code;
  67.     return( CONTINUE );
  68. }
  69.  
  70. int WASPSClicked( VOID )
  71. {
  72.     nP.Wasps = ASwarmMsg.Code;
  73.     return( CONTINUE );
  74. }
  75.  
  76. int BEESClicked( VOID )
  77. {
  78.     nP.Bees = ASwarmMsg.Code;
  79.     return( CONTINUE );
  80. }
  81.  
  82. int TIGHTNESSClicked( VOID )
  83. {
  84.     nP.Tightness = ASwarmMsg.Code;
  85.     return( CONTINUE );
  86. }
  87.  
  88. int COLORCYCLINGClicked( VOID )
  89. {
  90.     nP.Colorcycling = ASwarmMsg.Code;
  91.     return( CONTINUE );
  92. }
  93.  
  94. int AIMMODEClicked( VOID )
  95. {
  96.     nP.Aimmode = ASwarmMsg.Code;
  97.     return( CONTINUE );
  98. }
  99.  
  100. int ASwarmVanillaKey( VOID )
  101. {
  102.     switch( ASwarmMsg.Code ) {
  103.     case 'o':
  104.         return( OKClicked() );
  105.     case 't':
  106.         return( TESTClicked() );
  107.     case 'c':
  108.         return( CANCELClicked() );
  109.     case 'w':
  110.         GT_SetGadgetAttrs( ASwarmGadgets[GD_WASPS], ASwarmWnd, 0L, GTSL_Level, ++(nP.Wasps) > MAX_WASPS ?
  111.             nP.Wasps = MAX_WASPS : nP.Wasps, 0L );
  112.         return( CONTINUE );
  113.     case 'W':
  114.         GT_SetGadgetAttrs( ASwarmGadgets[GD_WASPS], ASwarmWnd, 0L, GTSL_Level, --(nP.Wasps) < 1 ?
  115.             nP.Wasps = 1 : nP.Wasps , 0L );
  116.         return( CONTINUE );
  117.     case 'e':
  118.         GT_SetGadgetAttrs( ASwarmGadgets[GD_BEES], ASwarmWnd, 0L, GTSL_Level, ++(nP.Bees) > MAX_BEES ?
  119.             nP.Bees = MAX_BEES : nP.Bees, 0L );
  120.         return( CONTINUE );
  121.     case 'E':
  122.         GT_SetGadgetAttrs( ASwarmGadgets[GD_BEES], ASwarmWnd, 0L, GTSL_Level, --(nP.Bees) < 1 ?
  123.             nP.Bees = 1 : nP.Bees, 0L );
  124.         return( CONTINUE );
  125.     case 'i':
  126.         GT_SetGadgetAttrs( ASwarmGadgets[GD_TIGHTNESS], ASwarmWnd, 0L, GTSL_Level, ++(nP.Tightness) > MAX_TIGHTNESS ?
  127.             nP.Tightness = MAX_TIGHTNESS : nP.Tightness, 0L );
  128.         return( CONTINUE );
  129.     case 'I':
  130.         GT_SetGadgetAttrs( ASwarmGadgets[GD_TIGHTNESS], ASwarmWnd, 0L, GTSL_Level, --(nP.Tightness) < 1 ?
  131.             nP.Tightness = 1 : nP.Tightness, 0L );
  132.         return( CONTINUE );
  133.     case 'l':
  134.     case 'L':
  135.         GT_SetGadgetAttrs( ASwarmGadgets[GD_COLORCYCLING], ASwarmWnd, 0L, GTCY_Active,
  136.             ++(nP.Colorcycling) > 1 ? nP.Colorcycling = 0 : nP.Colorcycling, 0L );
  137.         return( CONTINUE );
  138.     case 's':
  139.         GT_SetGadgetAttrs( ASwarmGadgets[GD_SPEED], ASwarmWnd, 0L, GTCY_Active, ++(nP.Speed) > MAX_SPEED ?
  140.             nP.Speed = MAX_SPEED : nP.Speed, 0L );
  141.         return( CONTINUE );
  142.     case 'S':
  143.         GT_SetGadgetAttrs( ASwarmGadgets[GD_SPEED], ASwarmWnd, 0L, GTCY_Active, --(nP.Speed) < 0 ?
  144.             nP.Speed = 0 : nP.Speed, 0L );
  145.         return( CONTINUE );
  146.     case 'm':
  147.     case 'M':
  148.         GT_SetGadgetAttrs( ASwarmGadgets[GD_AIMMODE], ASwarmWnd, 0L,  GTCY_Active, ++(nP.Aimmode) > 1 ?
  149.             nP.Aimmode = 0 : nP.Aimmode, 0L );
  150.         return( CONTINUE );
  151.     default:
  152.         return( CONTINUE );
  153.     }
  154.  
  155. }
  156.  
  157. VOID prefs( LONG command )
  158. {
  159.     switch( command ) {
  160.     case STARTUP:
  161.         CopyMem( prefData, &nP, sizeof( struct mPrefObject ));
  162.         if( !SetupScreen() ) {
  163.             if( !OpenASwarmWindow()) setASwarmPrefs();
  164.             CloseDownScreen();
  165.         }
  166.         break;
  167.     case IDCMP:
  168.         if( HandleASwarmIDCMP() != QUIT ) break;
  169.     case KILL:
  170.         CloseASwarmWindow();
  171.     }
  172. }
  173.  
  174. LONG winSig( VOID )
  175. {
  176.     return( ASwarmWnd ? 1L << ASwarmWnd->UserPort->mp_SigBit : 0L );
  177. }
  178.